﻿/// <reference path="jquery-1.4.1-vsdoc.js" />
(function ($) {
    $.extend({
        shareIt: {
            defaults: {
                iconPath: '/Icons/32x32/',
                targetId: '#shareIt',
                className: 'shareit',
                title: '',
                url: ''

            },
            options: {},

            _init: function (options) {
                this.options = jQuery.extend($.shareIt.options, $.shareIt.defaults, options || {});
            },


            show: function (_options) {
                //close all first
                this._init(_options);

                var _html = '';

                // Facebook                
                _html += '<a title="Facebook" href="http://www.facebook.com/sharer.php?u=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Facebook" title="Facebook" src="' + this.options.iconPath + '/facebook.png" /></a>';


                // Link Hay                
                _html += '<a title="Link Hay" href="http://linkhay.com/submit?link_url=' + this.options.url + '&link_title=' + this.options.title + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Link Hay" title="Link Hay" src="' + this.options.iconPath + '/linkhay.png" /></a>';

                //Digg

                _html += '<a title="Digg" href="http://digg.com/submit?phase=2&amp;url=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Digg" title="Digg" src="' + this.options.iconPath + '/digg.png" /></a>';

                // Tw
                _html += '<a title="TwitThis" href="http://twitter.com/home?status=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="TwitThis" title="TwitThis" src="' + this.options.iconPath + '/twitter.png" /></a>';

                //StumbleUpon
                _html += '<a title="StumbleUpon" href="http://www.stumbleupon.com/submit?url=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="StumbleUpon" title="StumbleUpon" src="' + this.options.iconPath + '/stumbleupon.png" /></a> ';

                //del.icio.us
                _html += '<a title="del.icio.us" href="http://del.icio.us/post?url=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="del.icio.us" title="del.icio.us" src="' + this.options.iconPath + '/delicious.png" /></a>';
                //Mixx
                _html += '<a title="Mixx" href="http://www.mixx.com/submit?page_url=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Mixx" title="Mixx" src="' + this.options.iconPath + '/mixx.png" /></a>';

                // Google
                _html += '<a title="Google" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Google" title="Google" src="' + this.options.iconPath + '/google.png" /></a>';

                //Linkin
                _html += '<a title="LinkedIn" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="LinkedIn" title="LinkedIn" src="' + this.options.iconPath + '/linkedin.png" /></a>';

                //Technorati
                _html += '<a title="Technorati" href="http://technorati.com/faves?add=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Technorati" title="Technorati" src="' + this.options.iconPath + '/technorati.png" /></a>';

                //Yahoo Buzz
                _html += '<a title="Yahoo Buzz" href="http://buzz.yahoo.com/buzz?publisherurn=VIGIADINH&targetUrl=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Yahoo Buzz" title="Yahoo Buzz" src="' + this.options.iconPath + '/yahoobuzz.png" /></a>';

                //Reddit
                _html += '<a title="Reddit" href="http://reddit.com/submit?url=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="Reddit" title="Reddit" src="' + this.options.iconPath + '/reddit.png" /></a>';

                //Email
                _html += '<a title="E-mail this story to a friend!" href="mailto:?subject=' + this.options.title + '&body=' + this.options.url + '" target="_blank" rel="nofollow"><img class="' + this.options.className + '" alt="E-mail this story to a friend!" title="E-mail this story to a friend!" src="' + this.options.iconPath + '/email.png" /></a>';

                $(this.options.targetId).html(_html);

                $(this.options.targetId + ' img')
                .css({ opacity: 0.5 })
                .mouseover(function () {
                    $(this).animate({ opacity: '1' });
                })
                .mouseout(function () {
                    $(this).animate({ opacity: 0.5 });
                });



            }


        }// end shareIt
    });   // end extend

})(jQuery);
